<?php


namespace App\Api\Filters;


use Illuminate\Support\Facades\Auth;

class BookCollectionFilter extends Filters
{
    protected $filters = [
        'me',
        'gender'
    ];

    protected function me(){

        if (! Auth::guard('api')->check()){
            abort(404);
        }

        $user = Auth::guard('api')->user();
        return $this->builder->where('user_id',$user->id);

    }

    public function gender($gender){

        if (!in_array($gender,[0,1])){
            abort(404);
        }

        return $this->builder->where('gender',$gender);

    }



}